package com.kelan.android.app.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kelan.android.app.entity.EasyUIDataGridResult;
import com.kelan.android.app.entity.ItemEntity;
import com.kelan.android.app.entity.ProcessEntity;
import com.kelan.android.app.service.CheckProcessService;
import com.kelan.android.app.service.ItemService;
/**
 * 
 * @ClassName: CheckProcessController
 * @Description:  多数据源示例使用方法
 * @Author 刘仁
 * @DateTime 2020年3月25日 下午2:43:01
 */
@RestController
@RequestMapping("/test")
public class CheckProcessController {

	@Autowired
	private CheckProcessService checkProcessService;
	
	@Autowired
	private ItemService itemService;
	
	@GetMapping("/test")
	@ResponseBody
	public EasyUIDataGridResult getStrList(@RequestParam(value="page",required = true, defaultValue = "1") Integer pageNum ,
            @RequestParam(value="rows",required = true, defaultValue = "10") Integer rows, ProcessEntity processEntity){
		PageHelper.startPage(pageNum , rows);
		List<ProcessEntity> list = checkProcessService.selectProcessList(processEntity);
		PageInfo<ProcessEntity> personPageInfo = new PageInfo<>(list);
		EasyUIDataGridResult dataGridResult = new EasyUIDataGridResult();
		dataGridResult.setTotal(Integer.parseInt(personPageInfo.getTotal()+""));
		dataGridResult.setRows(list);
		return dataGridResult;
	}
	
	@GetMapping("/test3")
	@ResponseBody
	public EasyUIDataGridResult listTh(@RequestParam(value="page",required = true, defaultValue = "1") Integer pageNum ,
            @RequestParam(value="rows",required = true, defaultValue = "10") Integer rows, ItemEntity itemEntity){
		PageHelper.startPage(pageNum , rows);
		List<ItemEntity> list = itemService.selectItemList(itemEntity);
		PageInfo<ItemEntity> personPageInfo = new PageInfo<>(list);
		EasyUIDataGridResult dataGridResult = new EasyUIDataGridResult();
		dataGridResult.setTotal(Integer.parseInt(personPageInfo.getTotal()+""));
		dataGridResult.setRows(list);
		return dataGridResult;
	}
}
